const path = require('path')
module.exports = {
  devServer: {
    port: 3000,
    open: true,
    proxy: {
      '/conner': {
        target: 'https://api.it120.cc',
        changeOrigin: true,
        // 路径重写
        pathRewrite: {
          '^/conner': '/conner'
        }
      },
      /*
        所有的以 /conner开头的请求（前面不能加源）,代理到 target这个源

        服务器发出去真实代理请求地址
          target(去掉/conner 前缀) + pathRewrite值 + 写的path

          https://api.it120.cc/conner/a/b/c

          https://api.it120.cc/a/b/c

      */
      '/api': {
        target: '另一个源',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
  },
  lintOnSave: false,
  // 路径别名
  chainWebpack: config => {
    config.resolve.alias
      .set('@', path.join(__dirname, 'src'))
      .set('@components', path.join(__dirname, 'src/components'))
      .set('@plugins', path.join(__dirname, 'src/plugins'))
      .set('@utils', path.join(__dirname, 'src/utils'))
      .set('@views', path.join(__dirname, 'src/views'))
      .set('@api', path.join(__dirname, 'src/api'))
  }
}
